
package com.scalar.chiptrack.operations.packingslip.forms;

import java.text.DecimalFormat;

import com.scalar.chiptrack.ChipTrackActionForm;
import com.scalar.chiptrack.commons.Address;
import com.scalar.chiptrack.commons.ClientInfo;
import com.scalar.chiptrack.operations.vendor.VendorAddress;


public final class CommercialInvoiceForm extends ChipTrackActionForm {


    private int m_salesOrderId              = -1;
    private int m_customerShippingId        = -1;
    private int odmId                       = -1;
    private int shippingFromLocationId      = -1;
    private int m_vendorLocationId          = -1;
    private int m_shipperId                 = -1;
    private int m_shippingId                = -1;
    private int m_billingId                 = -1;
    private int m_totalPackages             = -1;

    private String m_countryOfOrigin        = null;
    private String m_portOfLanding          = null;
    private String m_portOfDestination      = null;
    private String m_scheduleNumber         = null;
    private String m_packingSlipNumber      = null;
    private String m_totalWeight            = null;
    private String m_licenseSymbol          = null;
    private String m_eccn                   = null;
	private String m_contactPerson          = null;
	private String frieghtTrackingNumber[] = null;
	private String shippingTerms            = null;
    private String commercialInvoiceNo      = null;
    private String m_fob                    = null;
    private String m_status                 = null;
    private String m_clientName             = null;
    private String m_ccatsNumber            = null;
    private String mPackedby                = null;
    private String mTitle                   = null;
    private String comments                 = null;
    private String m_billingAddress         = null;
    private String m_shippingAddressAsString    = null;
    private String m_shipperAddressAsString = null;
    private String m_vendorName             = null;
  	private String 	m_shippedVia            = null;
    public static String m_clientNames      = null;
    private String supplierNumber           = null;
    private String odmSupplierNumber        = null;
    private String odm                      = null;
    private String shipperVendorAddressAsHTML="";
    private String countryOfFabOrigin       = null;
    private String countryOfAssyOrigin      = null;
    private String shipDate                 = null;
    private String grossWeight              = null;
    private String weightType               = null;

    private boolean isSample                = false;

    private Address m_shippingAddressObject = null;
    private Address m_shipperAddressObject  = null;
    private Address shippingVendorAddressObject = null;
    private Address m_shippingAddress       = null;
    private Address m_billingAddressObject  = null;
    private VendorAddress m_shipperAddress  = null;

    private ClientInfo clientInfo           = null;

    public CommercialInvoiceForm() { }

    public CommercialInvoiceForm( int customerShippingId,
                                  String packingSlipNumber,
                                  int totalPackages,
                                  String totalWeight,
                                  String countryOfOrigin,
                                  String portOfLanding,
                                  String portOfDestination,
                                  String licenseSymbol,
                                  String eccn )
    {
        m_customerShippingId = customerShippingId;
        m_packingSlipNumber  = packingSlipNumber;
        m_totalWeight        = totalWeight;
        m_totalPackages      = totalPackages;
        m_countryOfOrigin    = countryOfOrigin;
        m_portOfLanding      = portOfLanding;
        m_portOfDestination  = portOfDestination;
        m_licenseSymbol      = licenseSymbol;
        m_eccn               = eccn;
    }

    public CommercialInvoiceForm( int customerShippingId,
                                  String packingSlipNumber,
                                  int totalPackages,
                                  String totalWeight,
                                  String countryOfOrigin,
                                  String portOfLanding,
                                  String portOfDestination,
                                  String licenseSymbol,
                                  String eccn,
                                  String fob )
    {
        m_customerShippingId = customerShippingId;
        m_packingSlipNumber  = packingSlipNumber;
        m_totalWeight        = totalWeight;
        m_totalPackages      = totalPackages;
        m_countryOfOrigin    = countryOfOrigin;
        m_portOfLanding      = portOfLanding;
        m_portOfDestination  = portOfDestination;
        m_licenseSymbol      = licenseSymbol;
        m_eccn               = eccn;
        m_fob                = fob;

    }

    public boolean getIsSample()
    {
        return isSample;
    }
    public void setIsSample( boolean isSample )
    {
        this.isSample = isSample;
    }

    public String getShippingTerms() {
		return shippingTerms;
	}

	public void setShippingTerms(String shippingTerms) {
		this.shippingTerms = shippingTerms;
	}

    public int getSalesOrderId() {
        return m_salesOrderId;
    }
    public void setSalesOrderId (int salesOrderId) {
        m_salesOrderId = salesOrderId;
    }

    public int getPoSalesOrderId() {
        return m_salesOrderId;
    }
    public void setPoSalesOrderId (int salesOrderId) {
        m_salesOrderId = salesOrderId;
    }

    public int getCustomerShippingId() {
        return m_customerShippingId;
    }
    public void setCustomerShippingId (int customerShippingId) {
        m_customerShippingId = customerShippingId;
    }

    public String getCountryOfOrigin()
    {
        return m_countryOfOrigin;
    }
    public void setCountryOfOrigin( String countryOfOrigin )
    {
        m_countryOfOrigin = countryOfOrigin;
    }

    public String getPortOfLanding()
    {
        return m_portOfLanding;
    }
    public void setPortOfLanding( String portOfLanding )
    {
        m_portOfLanding = portOfLanding;
    }

    public String getPortOfDestination()
    {
        return m_portOfDestination;
    }
    public void setPortOfDestination( String portOfDestination )
    {
        m_portOfDestination = portOfDestination;
    }

    public String getScheduleNumber()
    {
        return m_scheduleNumber;
    }
    public void setScheduleNumber( String scheduleNumber )
    {
        m_scheduleNumber = scheduleNumber;
    }

    public String getPackingSlipNumber()
    {
        return m_packingSlipNumber;
    }
    public void setPackingSlipNumber( String packingSlipNumber)
    {
        m_packingSlipNumber = packingSlipNumber;
    }

    public String getEccn()
    {
        return m_eccn;
    }
    public void setEccn( String eccn )
    {
        m_eccn = eccn;
    }

    public String getLicenseSymbol()
    {
        return m_licenseSymbol;
    }
    public void setLicenseSymbol( String licenseSymbol )
    {
        m_licenseSymbol = licenseSymbol;
    }

    public int getTotalPackages()
    {
        return m_totalPackages;
    }
    public void setTotalPackages( int totalPackages )
    {
        m_totalPackages = totalPackages;
    }

    public String getTotalPackagesStr()
    {
        if( m_totalPackages == 0 )
        {
            return "";
        }
        else
        {
            return m_totalPackages + "";
        }
    }

    public void setTotalPackagesStr(String TotalPackagesStr)
    {
        if( TotalPackagesStr != null &&  TotalPackagesStr.trim().length() > 0 )
        {
            try
            {
                m_totalPackages = Integer.parseInt( TotalPackagesStr );
            }
            catch( NumberFormatException nfe ){  }
        }
        else if( TotalPackagesStr == null ||  TotalPackagesStr.trim().length() == 0 )
        {
            m_totalPackages = 0;
        }
    }

    public String getTotalWeight()
    {
        return getFormatedWeight( m_totalWeight );
    }
    public void setTotalWeight( String totalWeight )
    {
        m_totalWeight = getFormatedWeight( totalWeight );
    }

	public String getFormatedWeight( String weght )
	{
	    String weight = weght;
	    if ( weight != null )
	    {
		    if (  weight.equals("0.0") || weight.equals("0.00") )
            {
                weight = "";
            }
        }
		else if (  weight != null && weight.trim().length() > 0 )
        {
            DecimalFormat df = new DecimalFormat ( "########.00" );
            weight =  df.format( ( new Double( weight ).doubleValue() ) );
        }
		else
		{
            weight = "";
        }

		return weight;
    }

	public  String  getClientName()
	{
		  return m_clientName;
	}

	public  void setClientName( String clientName )
	{
		 m_clientName = clientName ;
	 }

    public  String  getCcatsNumber()
	{
		  return m_ccatsNumber;
	}

	public  void setCcatsNumber( String ccatsNumber )
	{
		 m_ccatsNumber = ccatsNumber ;
	 }

     public String getPackedby()
    {
        return mPackedby;
    }

    public void setPackedby( String packedby )
    {
        mPackedby = packedby;
    }

    public String getTitle()
    {
        return mTitle;
    }

    public void setTitle( String title )
    {
        mTitle = title;
    }


    public VendorAddress getShipperAddress()
    {
        if( m_shipperAddress != null )
        {
            return m_shipperAddress;
        }

        return new VendorAddress();
    }
    public void setShipperAddress( VendorAddress shipperAddress )
    {
        m_shipperAddress = shipperAddress;
    }

    public void setFob(String fob){
       m_fob = fob;
    }
    public String getFob(){
        return m_fob;
    }

    public void setStatus(String status){
       m_status = status;
    }
    public String getStatus(){
        return m_status;
    }

    public Address getShippingAddress()
    {
        if( m_shippingAddress != null )
        {
            return m_shippingAddress;
        }

        return new Address();
    }
    public void setShippingAddress ( Address shippingAddress )
    {
        m_shippingAddress = shippingAddress;
    }

	public String getContactPerson()
    {
        return m_contactPerson;
    }
    public void setContactPerson( String contactPerson )
    {
        m_contactPerson = contactPerson;
    }

    public String[] getFrieghtTrackingNumber()
    {
        return frieghtTrackingNumber;
    }

    public void setFrieghtTrackingNumber(String[] strings)
    {
        frieghtTrackingNumber = strings;
    }

    public String getComments()
    {
        return comments;
    }

    public void setComments(String string)
    {
        comments = string;
    }

    public String getShippedVia() {
        return m_shippedVia;
    }
    public void setShippedVia (String shippedVia) {
        m_shippedVia = shippedVia;
    }

    public int getVendorLocationId() {
        return m_vendorLocationId;
    }

    public void setVendorLocationId(int vendorLocationId) {
        m_vendorLocationId = vendorLocationId;
    }

    public String getVendorName() {
        return m_vendorName;
    }

    public void setVendorName(String vendorName) {
        m_vendorName = vendorName;
    }

    public int getBillingId() {
        return m_billingId;
    }

    public void setBillingId(int billingId) {
        m_billingId = billingId;
    }

    public int getShippingId() {
        return m_shippingId;
    }

    public void setShippingId(int shippingId) {
        m_shippingId = shippingId;
    }

    public String getBillingAddress() {
        return m_billingAddress;
    }

    public void setBillingAddress(String billingAddress) {
        m_billingAddress = billingAddress;
    }

    public Address getBillingAddressObject() {
            return m_billingAddressObject;
    }

    public void setBillingAddressObject(Address billingAddressObject) {
        m_billingAddressObject = billingAddressObject;
    }


    public String getShippingAddressAsString() {
        return m_shippingAddressAsString;
    }

    public void setShippingAddressAsString(String shippingAddressAsString) {
        m_shippingAddressAsString = shippingAddressAsString;
    }

    public Address getShippingAddressObject() {
        return m_shippingAddressObject;
    }

    public void setShippingAddressObject(Address shippingAddressObject) {
        m_shippingAddressObject = shippingAddressObject;
    }

    public int getShipperId() {
            return m_shipperId;
    }

    public void setShipperId(int shipperId) {
        m_shipperId = shipperId;
    }

    public String getShipperAddressAsString() {
        return m_shipperAddressAsString;
    }

    public void setShipperAddressAsString(String shipperAddressAsString) {
        m_shipperAddressAsString = shipperAddressAsString;
    }


    public Address getShipperAddressObject() {
        return m_shipperAddressObject;
    }

    public void setShipperAddressObject(Address shipperAddressObject) {
        m_shipperAddressObject = shipperAddressObject;
    }

    private String billingAddressAsHTML="";
    public String getBillingAddressAsHTML()
    {
        if ( m_billingAddressObject != null )
        {
            billingAddressAsHTML = m_billingAddressObject.getAddressAsHTML();
        }
        return billingAddressAsHTML;
    }

    private String shippingAddressAsHTML="";
    public String getShippingAddressAsHTML()
    {
        if ( m_shippingAddressObject != null )
        {
            shippingAddressAsHTML = m_shippingAddressObject.getAddressAsHTML();
        }

        return shippingAddressAsHTML;
    }

    private String shipperAddressAsHTML="";
    public String getShipperAddressAsHTML()
    {
        shipperAddressAsHTML = convertAddressObjToHtml(m_shipperAddressAsString);
        return shipperAddressAsHTML;
    }

    public String getSupplierNumber() {
            return supplierNumber;
    }

    public void setSupplierNumber(String supplierNumber) {
        this.supplierNumber = supplierNumber;
    }

    public String getOdmSupplierNumber() {
        return odmSupplierNumber;
    }

    public void setOdmSupplierNumber(String odmSupplierNumber) {
        this.odmSupplierNumber = odmSupplierNumber;
    }

    public String getOdm() {
        return odm;
    }

    public void setOdm(String odm) {
        this.odm = odm;
    }

    public int getOdmId() {
        return odmId;
    }

    public void setOdmId(int odmId) {
        this.odmId = odmId;
    }

    public String convertAddressObjToHtml(String convertStr)
    {
        StringBuffer sb=new StringBuffer("");
        String tempStr = "";
        if( convertStr == null )
        {
            convertStr = "";
        }
        for(int i=0;i<convertStr.length();i++)
        {
            char ch = convertStr.charAt(i);

            if(ch == '\n')
            {
                sb.append("<br>");
            }
            else
            {
                sb.append(ch);
            }
        }

        tempStr = sb.toString().replaceAll("<br><br><br>","<br><br>");
        return tempStr;
    }

    public String convertAddressObjToXml(Address add)
    {
         return convertAddressObjToXml(add, null);
    }

    public String convertAddressObjToXml(Address add, String customerName)
    {
        StringBuffer sb=new StringBuffer("");

        if ( ( customerName != null ) && (customerName.trim().length() > 0 ) )
        {
            if ( ! customerName.equals( add.getContactPerson() ) )
                sb.append ( "<name><![CDATA[" + customerName + "]]></name>\n" );
        }
        sb.append ( "<contactPerson><![CDATA[" + ( ( ( add.getContactPerson() == null ) || ( add.getContactPerson().trim().length() == 0 ) ) ? "" : add.getContactPerson() ) + " ]]></contactPerson>\n"   );
        sb.append ( "<address1><![CDATA[" + ( ( ( add.getAddress1() == null ) || ( add.getAddress1().trim().length() == 0 ) ) ? "" : add.getAddress1() ) + "]]></address1>\n"   );
        sb.append ( "<address2><![CDATA[" + ( ( ( add.getAddress2() == null ) || ( add.getAddress2().trim().length() == 0 ) ) ? "" : add.getAddress2() ) +  "]]></address2>\n"   );
        sb.append ( "<address3><![CDATA[" + ( ( ( add.getAddress3() == null ) || ( add.getAddress3().trim().length() == 0 ) ) ? "" : add.getAddress3() ) +  "]]></address3>\n"   );
        sb.append ( "<address4><![CDATA[" + ( ( ( add.getAddress4() == null ) || ( add.getAddress4().trim().length() == 0 ) ) ? "" : add.getAddress4() ) +  "]]></address4>\n"   );
        sb.append ( "<city><![CDATA[" + ( ( ( add.getCity()== null )||( add.getCity().trim().length() == 0 ))  ? "" : add.getCity() ) + "]]></city>\n" );
        String formatedState  = PackingSlipForm.getFormatedStateXPDL( add );
        if ( formatedState.trim().length() > 0 )
            sb.append ( "<state><![CDATA["  + formatedState + "]]></state>" );
        /*sb.append ( "<phone><![CDATA[" + ( ( ( add.getPhoneNumber()== null )||( add.getPhoneNumber().trim().length() == 0 ))  ? "\n\nTel: " : "\n\nTel: " + add.getPhoneNumber() ) + "]]></phone>\n" );
        sb.append ( "<cellno><![CDATA[" + ( ( ( add.getCellNumber()== null )||( add.getCellNumber().trim().length() == 0 ))  ? "Cell No: " :"Cell No: " + add.getCellNumber() ) + "]]></cellno>\n" );
        sb.append ( "<fax><![CDATA[" + ( ( ( add.getFaxNumber()== null )||( add.getFaxNumber().trim().length() == 0 ))  ? "Fax: " :"Fax: " + add.getFaxNumber() ) + "]]></fax>\n" );
        sb.append ( "<email><![CDATA[" + ( ( ( add.getEmail()== null )||( add.getEmail().trim().length() == 0 ))  ? "Email: " : "Email: " + add.getEmail() ) + "]]></email>\n" ); */
        //modified by varma 06 jul 2004
        sb.append ( "<phone><![CDATA[" + ( ( ( add.getPhoneNumber()!= null ) && ( add.getPhoneNumber().trim().length() != 0 ))  ? "\n\nTel: " + add.getPhoneNumber()  : "") + "]]></phone>\n" );
        sb.append ( "<cellno><![CDATA[" + ( ( ( add.getCellNumber()!= null ) && ( add.getCellNumber().trim().length() != 0 ))  ? "Cell No: " + add.getCellNumber() : "" ) + "]]></cellno>\n" );
        sb.append ( "<fax><![CDATA[" + ( ( ( add.getFaxNumber()!= null ) && ( add.getFaxNumber().trim().length() != 0 ))  ? "Fax: " + add.getFaxNumber() : "" ) + "]]></fax>\n" );
        sb.append ( "<email><![CDATA[" + ( ( ( add.getEmail()!= null ) && ( add.getEmail().trim().length() != 0 ))  ?  "Email: " + add.getEmail() : "") + "]]></email>\n" );


        return  sb.toString();
    }

    public String convertAddressObjToHtml(Address add)
    {
         return convertAddressObjToHtml(add, null);
    }

    public String convertAddressObjToHtml(Address add, String customerName)
    {
        StringBuffer sb=new StringBuffer("");

        if ( customerName != null  )
        {

            if ( ( add.getContactPerson() != null ) && (add.getContactPerson().trim().length() > 0 ) )
            {
                if ( ! customerName.equals( add.getContactPerson() ) )
                {
                    sb.append( ( customerName.trim().length() > 0 ) ? customerName + "<br>" : "" );
                    sb.append( ( ( add.getContactPerson() == null ) || ( add.getContactPerson().trim().length() == 0 ) ) ? "" : add.getContactPerson());
                }
                else
                {
                    sb.append( ( customerName.trim().length() > 0 ) ? customerName  : "" );
                }
            }
            else
            {
                sb.append( ( customerName.trim().length() > 0 ) ? customerName  : "" );
            }

        }
        else
        {
            sb.append( ( ( add.getContactPerson() == null ) || ( add.getContactPerson().trim().length() == 0 ) ) ? "" : "C/O "+add.getContactPerson());
        }
        //sb.append( ( ( add.getContactPerson() == null ) || ( add.getContactPerson().trim().length() == 0 ) ) ? "" : add.getContactPerson());
        sb.append( ( ( add.getAddress1() == null ) || ( add.getAddress1().trim().length() == 0 ) ) ? "" :"<br>"+ add.getAddress1()  );
        sb.append( ( ( add.getAddress2() == null ) || ( add.getAddress2().trim().length() == 0 ) ) ? "" : "<br>"+ add.getAddress2() );
        sb.append( ( ( add.getAddress3() == null ) || ( add.getAddress3().trim().length() == 0 ) ) ? "" : "<br>"+ add.getAddress3()  );
        sb.append( ( ( add.getAddress4() == null ) || ( add.getAddress4().trim().length() == 0 ) ) ? "" : "<br>"+ add.getAddress4() );
        sb.append( ( ( ( add.getCity() == null) || ( add.getCity().trim().length() == 0 ) ) ? "" : "<br>"  + add.getCity() ) );
        String formatedState  = "";
        formatedState = PackingSlipForm.getFormatedState( add );
        if ( formatedState.trim().length() > 0 )
           sb.append( "<br>"+formatedState );
       /* sb.append( ( ( ( add.getPhoneNumber() == null) || ( add.getPhoneNumber().trim().length() == 0 ) ) ? "<br><br>Tel: " : "<br><br>"  + "Tel: " + add.getPhoneNumber() ) );
        sb.append( ( ( ( add.getCellNumber() == null) || ( add.getCellNumber().trim().length() == 0 ) ) ? "<br>Cell No: " : "<br>"  + "Cell No: " + add.getCellNumber() ) );
        sb.append( ( ( ( add.getFaxNumber() == null) || ( add.getFaxNumber().trim().length() == 0 ) ) ? "<br>Fax: " : "<br>"  + "Fax: " + add.getFaxNumber() ) );
        sb.append( ( ( ( add.getEmail() == null) || ( add.getEmail().trim().length() == 0 ) ) ? "<br>Email: " : "<br>"  + "Email: " + add.getEmail()) ); */
        //modified by varma(066jun2004)
         sb.append( ( ( ( add.getPhoneNumber()!= null) && ( add.getPhoneNumber().trim().length() != 0 ) ) ?  "<br><br>"  + "Tel: " + add.getPhoneNumber() : "" ) );
        sb.append( ( ( ( add.getCellNumber() != null) && ( add.getCellNumber().trim().length() != 0 ) ) ?  "<br>"  + "Cell No: " + add.getCellNumber() : "") );
        sb.append( ( ( ( add.getFaxNumber() != null) && ( add.getFaxNumber().trim().length() != 0 ) ) ?  "<br>"  + "Fax: " + add.getFaxNumber()  : "") );
        sb.append( ( ( ( add.getEmail() != null) && ( add.getEmail().trim().length() != 0 ) ) ?  "<br>"  + "Email: " + add.getEmail() : "") );

        return  sb.toString();
    }

    public ClientInfo getClientInfo()
    {
        return clientInfo;
    }

    public void setClientInfo(ClientInfo info)
    {
        clientInfo = info;
        CommercialInvoiceForm.m_clientNames = clientInfo.getClientName();
    }

    public String getClientAddrWithOutEmailObjFormatted()
	{
        Address add = clientInfo.getAddress();
        StringBuffer formatAddress = new StringBuffer();

        try{
        formatAddress.append ( ( ( add.getAddress1() == null ) || ( ( add.getAddress1().trim().length() == 0 ) ) ) ? "" :"<BR>" +  add.getAddress1() );
        formatAddress.append ( ( ( add.getAddress2() == null ) || ( ( add.getAddress2().trim().length() == 0 ) ) ) ? "" :"<BR>" + add.getAddress2() );
        formatAddress.append ( ( ( add.getAddress3() == null ) || ( ( add.getAddress3().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress3() );
        formatAddress.append ( ( ( add.getAddress4() == null ) || ( ( add.getAddress4().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress4() );
        formatAddress.append ( ( ( add.getCity() == null ) || ( add.getCity().trim().length()==0 ) ) ? "" : "<BR>" +  add.getCity() );
        String formatState = PackingSlipForm.getFormatedState(add);
        if ( formatState.trim().length() !=0 )
           formatAddress.append ("<br>"+formatState);
        formatAddress.append ( ( ( add.getPhoneNumber() != null ) && ( add.getPhoneNumber().trim().length() > 0 ) ) ?  "<BR>Tel: "+ add.getPhoneNumber() : "" );
        formatAddress.append ( ( ( add.getFaxNumber() != null ) && ( add.getFaxNumber().trim().length() > 0 ) ) ?  "<BR>Fax: "+ add.getFaxNumber() : "" );
        }
        catch(Exception e)
        {
           e.printStackTrace();
        }
        return formatAddress.toString() ;

	}

    private String clientAddressAsHTMLAirgo="";
    public String getClientAddressAsHTMLAirgo()
    {
        clientAddressAsHTMLAirgo = getFormattedAddressAirgoWithoutEmail(clientInfo.getAddress());
        return clientAddressAsHTMLAirgo;
    }

    private String billingAddressAsHTMLAirgo="";
    public String getBillingAddressAsHTMLAirgo()
    {
        billingAddressAsHTMLAirgo = getFormattedAddressAirgo(m_billingAddressObject);
        return billingAddressAsHTMLAirgo;
    }

    private String shippingAddressAsHTMLAirgo="";
    public String getShippingAddressAsHTMLAirgo()
    {
        shippingAddressAsHTMLAirgo = getFormattedAddressAirgo(m_shippingAddressObject);
        return shippingAddressAsHTMLAirgo;
    }

    private String shipperAddressAsHTMLAirgo="";
    public String getShipperAddressAsHTMLAirgo()
    {
        shipperAddressAsHTMLAirgo = getFormattedAddressAirgo(m_shipperAddressObject);
        return shipperAddressAsHTMLAirgo;
    }

    public Address getShippingVendorAddressObject() {
        return shippingVendorAddressObject;
    }

    public void setShippingVendorAddressObject(Address shippingVendorAddressObject) {
        this.shippingVendorAddressObject = shippingVendorAddressObject;
    }


    public String getShipperVendorAddressAsHTML()
    {
        shipperVendorAddressAsHTML = convertAddressObjToHtml(shippingVendorAddressObject);
        return shipperVendorAddressAsHTML;
    }

    public int getShippingFromLocationId() {
        return shippingFromLocationId;
    }

    public void setShippingFromLocationId(int shippingFromLocationId) {
        this.shippingFromLocationId = shippingFromLocationId;
    }

    public static String getFormattedAddressAirgo( Address add )
          {

              StringBuffer formatAddress = new StringBuffer();

              if (add != null) {
                  formatAddress.append ( add.getAddress1() );
                  if( add.getAddress1() != null && !( add.getAddress1().trim().length() == 0 ) && add.getAddress2() != null && !( add.getAddress2().trim().length() == 0 ) )
                  formatAddress.append ( ", " );
                  formatAddress.append ( add.getAddress2() );

                  if( ( add.getAddress3() != null && !add.getAddress3().trim().equalsIgnoreCase( "" ) ) || ( add.getAddress4() != null && !add.getAddress4().trim().equalsIgnoreCase( "" ) ) )
                  formatAddress.append ( "<BR>" );

                  formatAddress.append ( add.getAddress3 () );
                  if( add.getAddress3() != null && !add.getAddress3().trim().equalsIgnoreCase( "" ) && add.getAddress4() != null && !add.getAddress4().trim().equalsIgnoreCase( "" ) )
                  formatAddress.append ( ", " );
                  formatAddress.append ( add.getAddress4() );


                  StringBuffer cityStateZip = new StringBuffer ( "" );

                   if ( add.getCity () != null && !add.getCity ().equals ( "" )) cityStateZip.append ( add.getCity () );
                   // add ',' only if city, state, zip are not empty
                   if ( ( add.getCity () != null &&  !add.getCity().equals ( "" ) ) && ( ( add.getState () != null  && !add.getState().equals ( "" ) ) || ( add.getZipCode () != null && !add.getZipCode().equals ( "" )) ) )
                   cityStateZip.append ( ", " );
                   if ( add.getState () != null  && !add.getState ().equals ( "" ) ) cityStateZip.append ( add.getState () );
                   // Add '-' only if there is state and Zip also
                   if ( ( add.getState () != null && !add.getState ().equals ( "" ) ) && ( add.getZipCode () != null && !add.getZipCode ().equals ( "" )) ) cityStateZip.append ( " - " );
                   if ( add.getZipCode () != null  && !add.getZipCode ().equals ( "" ) ) cityStateZip.append ( add.getZipCode () );
                   // add ',' if any of the above is present
                   if ( ( ( add.getCity () != null && !add.getCity ().equals ( "" )) || ( add.getState () != null && !add.getState ().equals ( "" ) ) || ( add.getZipCode () != null && !add.getZipCode ().equals ( "" ) ) ) && ( add.getCountry () != null && !add.getCountry ().equalsIgnoreCase( "" )) ) cityStateZip.append ( ", " );
                   cityStateZip.append ( add.getCountry () );

                  if( cityStateZip != null && cityStateZip.toString().trim().length() > 0  )
                  {
                      formatAddress.append ( "<BR>" + cityStateZip );
                  }

                  StringBuffer phFax = new StringBuffer ();
                   if( add.getPhoneNumber () != null  && !add.getPhoneNumber ().equals ( "" ) ) phFax.append ( "T:" + add.getPhoneNumber () );
                   if( ( add.getPhoneNumber () != null && !add.getPhoneNumber ().equals ( "" ) ) && ( add.getFaxNumber () != null && !add.getFaxNumber ().equals ( "" ) ) ) phFax.append ( "," );
                   if( add.getFaxNumber () != null && !add.getFaxNumber ().equals ( "" )  ) phFax.append ( "F:" + add.getFaxNumber () );

                  if( phFax != null && phFax.toString().trim().length() > 0  )
                  {
                      formatAddress.append ( "<BR>" + phFax );
                  }

                  if(  add.getEmail() != null && add.getEmail().trim().length() > 0 )
                  {
                      formatAddress.append ( "<BR>"+"Email: " + add.getEmail().trim() );
                  }
              }
              return formatAddress.toString() ;
          }


       public static String getFormattedAddressAirgoWithoutEmail( Address add )
       {

                  StringBuffer formatAddress = new StringBuffer();

                  if (add != null) {
                      formatAddress.append ( add.getAddress1() );
                      if( add.getAddress1() != null && !( add.getAddress1().trim().length() == 0 ) && add.getAddress2() != null && !( add.getAddress2().trim().length() == 0 ) )
                      formatAddress.append ( ", " );
                      formatAddress.append ( add.getAddress2() );

                      if( ( add.getAddress3() != null && !add.getAddress3().trim().equalsIgnoreCase( "" ) ) || ( add.getAddress4() != null && !add.getAddress4().trim().equalsIgnoreCase( "" ) ) )
                      formatAddress.append ( "<BR>" );

                      formatAddress.append ( add.getAddress3 () );
                      if( add.getAddress3() != null && !add.getAddress3().trim().equalsIgnoreCase( "" ) && add.getAddress4() != null && !add.getAddress4().trim().equalsIgnoreCase( "" ) )
                      formatAddress.append ( ", " );
                      formatAddress.append ( add.getAddress4() );


                      StringBuffer cityStateZip = new StringBuffer ( "" );

                       if ( add.getCity () != null && !add.getCity ().equals ( "" )) cityStateZip.append ( add.getCity () );
                       // add ',' only if city, state, zip are not empty
                       if ( ( add.getCity () != null &&  !add.getCity().equals ( "" ) ) && ( ( add.getState () != null  && !add.getState().equals ( "" ) ) || ( add.getZipCode () != null && !add.getZipCode().equals ( "" )) ) )
                       cityStateZip.append ( ", " );
                       if ( add.getState () != null  && !add.getState ().equals ( "" ) ) cityStateZip.append ( add.getState () );
                       // Add '-' only if there is state and Zip also
                       if ( ( add.getState () != null && !add.getState ().equals ( "" ) ) && ( add.getZipCode () != null && !add.getZipCode ().equals ( "" )) ) cityStateZip.append ( " - " );
                       if ( add.getZipCode () != null  && !add.getZipCode ().equals ( "" ) ) cityStateZip.append ( add.getZipCode () );
                       // add ',' if any of the above is present
                       if ( ( ( add.getCity () != null && !add.getCity ().equals ( "" )) || ( add.getState () != null && !add.getState ().equals ( "" ) ) || ( add.getZipCode () != null && !add.getZipCode ().equals ( "" ) ) ) && ( add.getCountry () != null && !add.getCountry ().equalsIgnoreCase( "" )) ) cityStateZip.append ( ", " );
                       cityStateZip.append ( add.getCountry () );

                      if( cityStateZip != null && cityStateZip.toString().trim().length() > 0  )
                      {
                          formatAddress.append ( "<BR>" + cityStateZip );
                      }

                      StringBuffer phFax = new StringBuffer ();
                       if( add.getPhoneNumber () != null  && !add.getPhoneNumber ().equals ( "" ) ) phFax.append ( "T:" + add.getPhoneNumber () );
                       if( ( add.getPhoneNumber () != null && !add.getPhoneNumber ().equals ( "" ) ) && ( add.getFaxNumber () != null && !add.getFaxNumber ().equals ( "" ) ) ) phFax.append ( "," );
                       if( add.getFaxNumber () != null && !add.getFaxNumber ().equals ( "" )  ) phFax.append ( "F:" + add.getFaxNumber () );

                      if( phFax != null && phFax.toString().trim().length() > 0  )
                      {
                          formatAddress.append ( "<BR>" + phFax );
                      }

                  }
                  return formatAddress.toString() ;
              }


    public String getFormattedAddress( Address add )
	{
		StringBuffer formatAddress = new StringBuffer();
        formatAddress.append ( ( ( add.getContactPerson() == null ) || ( ( add.getContactPerson().trim().length() == 0 ) ) ) ? "" :"<BR>" +  add.getContactPerson() );
		formatAddress.append ( ( ( add.getAddress1() == null ) || ( ( add.getAddress1().trim().length() == 0 ) ) ) ? "" :"<BR>" +  add.getAddress1() );

		formatAddress.append ( ( ( add.getAddress2() == null ) || ( ( add.getAddress2().trim().length() == 0 ) ) ) ? "" :"<BR>" + add.getAddress2() );

		formatAddress.append ( ( ( add.getAddress3() == null ) || ( ( add.getAddress3().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress3() );

		formatAddress.append ( ( ( add.getAddress4() == null ) || ( ( add.getAddress4().trim().length() == 0 ) ) ) ? "" : "<BR>" + add.getAddress4() );

		formatAddress.append ( ( ( add.getCity() == null ) || ( add.getCity().trim().length()==0 ) ) ? "" : "<BR>" +  add.getCity() );

		String formatedState = PackingSlipForm.getFormatedState( add ); // Added by neelima
		if ( formatedState.trim().length() > 0 )
        	formatAddress.append ( "<br>" + formatedState );

        formatAddress.append ( ( ( add.getPhoneNumber() != null ) && ( add.getPhoneNumber().trim().length() > 0 ) ) ?  "<BR><BR>Tel: "+ add.getPhoneNumber() : "" );
        formatAddress.append ( ( ( add.getCellNumber() != null ) && ( add.getCellNumber().trim().length() > 0 ) ) ? "<BR>Cell No: "+ add.getCellNumber() : "");
        formatAddress.append ( ( ( add.getFaxNumber() != null ) && ( add.getFaxNumber().trim().length() > 0 ) ) ?  "<BR>Fax: "+ add.getFaxNumber() : "" );
        formatAddress.append ( ( ( add.getEmail() != null ) && ( add.getEmail().trim().length() > 0 ) ) ?  "<BR>Email: "+ add.getEmail() : "" );


		return formatAddress.toString() ;
	}

    public String convertVendorAddressObjToXml(Address add )
    {
        StringBuffer sb=new StringBuffer("");

        sb.append ( "<contactPerson><![CDATA[" + ( ( ( add.getContactPerson() == null ) || ( add.getContactPerson().trim().length() == 0 ) ) ? "" : add.getContactPerson() ) + " ]]></contactPerson>\n"   );
        sb.append ( "<address1><![CDATA[" + ( ( ( add.getAddress1() == null ) || ( add.getAddress1().trim().length() == 0 ) ) ? "" : add.getAddress1() ) + "]]></address1>\n"   );
        sb.append ( "<address2><![CDATA[" + ( ( ( add.getAddress2() == null ) || ( add.getAddress2().trim().length() == 0 ) ) ? "" : add.getAddress2() ) +  "]]></address2>\n"   );
        sb.append ( "<address3><![CDATA[" + ( ( ( add.getAddress3() == null ) || ( add.getAddress3().trim().length() == 0 ) ) ? "" : add.getAddress3() ) +  "]]></address3>\n"   );
        sb.append ( "<address4><![CDATA[" + ( ( ( add.getAddress4() == null ) || ( add.getAddress4().trim().length() == 0 ) ) ? "" : add.getAddress4() ) +  "]]></address4>\n"   );
        sb.append ( "<city><![CDATA[" + ( ( ( add.getCity()== null )||( add.getCity().trim().length() == 0 ))  ? "" : add.getCity() ) + "]]></city>\n" );
        String formatedState  = PackingSlipForm.getFormatedStateXPDL( add );
        if ( formatedState.trim().length() > 0 )
        {
            sb.append ( "<state><![CDATA["  + formatedState + "]]></state>" );
        }
        sb.append ( "<phone><![CDATA[" + ( ( ( add.getPhoneNumber()!= null ) && ( add.getPhoneNumber().trim().length() != 0 ))  ? "\n\nTel: " + add.getPhoneNumber()  : "") + "]]></phone>\n" );
        sb.append ( "<cellno><![CDATA[" + ( ( ( add.getCellNumber()!= null ) && ( add.getCellNumber().trim().length() != 0 ))  ? "Cell No: " + add.getCellNumber() : "" ) + "]]></cellno>\n" );
        sb.append ( "<fax><![CDATA[" + ( ( ( add.getFaxNumber()!= null ) && ( add.getFaxNumber().trim().length() != 0 ))  ? "Fax: " + add.getFaxNumber() : "" ) + "]]></fax>\n" );
        sb.append ( "<email><![CDATA[" + ( ( ( add.getEmail()!= null ) && ( add.getEmail().trim().length() != 0 ))  ?  "Email: " + add.getEmail() : "") + "]]></email>\n" );


        return  sb.toString();
    }

    public String getCountryOfFabOrigin() {
        return countryOfFabOrigin;
    }

    public void setCountryOfFabOrigin(String countryOfFabOrigin) {
        this.countryOfFabOrigin = countryOfFabOrigin;
    }

    public String getCountryOfAssyOrigin() {
        return countryOfAssyOrigin;
    }

    public void setCountryOfAssyOrigin(String countryOfAssyOrigin) {
        this.countryOfAssyOrigin = countryOfAssyOrigin;
    }

    public String getClientAddressXMLFormatted( )
    {
        Address add = clientInfo.getAddress();
        StringBuffer formatAddress = new StringBuffer();

        formatAddress.append( "<address1><![CDATA[" );
        formatAddress.append ( ( ( add.getAddress1() == null ) || ( ( add.getAddress1().trim().length() == 0 ) ) ) ? "" : add.getAddress1() );
        formatAddress.append ( "]]></address1> \n" );
        formatAddress.append( "<address2><![CDATA[" );
        formatAddress.append ( ( ( add.getAddress2() == null ) || ( ( add.getAddress2().trim().length() == 0 ) ) ) ? "" : add.getAddress2() );

        formatAddress.append ( "]]></address2> \n" );
        formatAddress.append( "<address3><![CDATA[" );
        formatAddress.append ( ( ( add.getAddress3() == null ) || ( ( add.getAddress3().trim().length() == 0 ) ) ) ? "" : add.getAddress3() );
        formatAddress.append ( "]]></address3> \n" );

        formatAddress.append( "<address4><![CDATA[" );
        formatAddress.append ( ( ( add.getAddress4() == null ) || ( ( add.getAddress4().trim().length() == 0 ) ) ) ? "" : add.getAddress4() );
        formatAddress.append ( "]]></address4> \n" );

        /*formatAddress.append( "<city><![CDATA[" );
        formatAddress.append ( ( ( add.getCity() == null ) || ( add.getCity().trim().length()==0 ) ) ? "" : add.getCity() );
        formatAddress.append ( "]]></city> \n" );*/
	    String formatedState = "";
	    formatedState = PackingSlipForm.getFormatedCityStateXPDL(add);
		if ( formatedState.trim().length() > 0 )
		   formatAddress.append( "<state><![CDATA["+formatedState+"]]></state> \n" );

        formatAddress.append ( "<phone><![CDATA[" );
        formatAddress.append ( ( ( add.getPhoneNumber() != null ) && ( add.getPhoneNumber().trim().length() > 0 ) ) ?  "Tel: "+ add.getPhoneNumber()+"" : "" ); //modified by varma 06 jul 2004
        formatAddress.append ( "]]></phone> \n" );

        formatAddress.append ( "<fax><![CDATA[" );
        formatAddress.append ( ( ( add.getFaxNumber() != null ) && ( add.getFaxNumber().trim().length() > 0 ) ) ? "Fax: "+ add.getFaxNumber() : "" ); //modified by varma 06 jul 2004
        formatAddress.append ( "]]></fax> \n" );
	    formatAddress.append ( "<email><![CDATA[" );
        formatAddress.append ( ( ( add.getEmail() != null ) && ( add.getEmail().trim().length() > 0 ) ) ? "Email: "+ add.getEmail() : "" );     //modified by varma 06 jul 2004
        formatAddress.append ( "]]></email> \n" );

        return formatAddress.toString() ;
    }


    public String getShipDate()
    {
        return shipDate;
    }

    public void setShipDate(String shipDate)
    {
        this.shipDate = shipDate;
    }


    public String getCommercialInvoiceNo() {
        return commercialInvoiceNo;
    }

    public void setCommercialInvoiceNo(String commercialInvoiceNo) {
        this.commercialInvoiceNo = commercialInvoiceNo;
    }


    public String getGrossWeight() {
        return grossWeight;
    }

    public void setGrossWeight(String grossWeight) {
        this.grossWeight = grossWeight;
    }

    public String getWeightType() {
        return weightType;
    }

    public void setWeightType(String weightType) {
        this.weightType = weightType;
    }
}